<template>
  <!-- 审核提交弹窗组件 -->
  <div>
    <zm-panel
      title="确认提示"
      :visible.sync="params.visible"
      class="panelContainer"
      :before-close="onCancel"
      @cancel="onCancel"
      @confirm="submit"
      ok-text="确认提交"
    >
      <zm-form>
      <el-row :gutter="24">
        <el-col :span="8">
          <zm-form-item label="业务员:">{{ params.obj.salemanName }}</zm-form-item>
        </el-col>
        <el-col :span="8">
          <zm-form-item label="所属部门:">{{ params.obj.apartmentName }}</zm-form-item>
        </el-col>
        <el-col :span="8">
          <zm-form-item label="回款单数:">{{ params.obj.returnedNumber }}</zm-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24">
        <el-col :span="8">
          <zm-form-item label="当月回款总额:">{{ params.obj.returnedMoney }}</zm-form-item>
        </el-col>
        <el-col :span="8">
          <zm-form-item label="应发提成:">{{ params.obj.shouldPrice }}</zm-form-item>
        </el-col>
        <el-col :span="8">
          <zm-form-item label="核发提成:">{{ params.obj.verifyPrice }}</zm-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24">
        <el-col :span="24">
          <zm-form-item label="业绩备注:">
            <el-input
              type="textarea"
              placeholder="备注"
              v-model="remark"
              maxlength="300"
              show-word-limit
              resize="none"
            />
          </zm-form-item>
        </el-col>
      </el-row>
       <el-alert
        title="是否确定业绩提成，确认后将提交至业务员进行确认"
        type="warning"
        show-icon
      />
</zm-form>
    </zm-panel>
  </div>
</template>

<script>
import dialogMixin from '@/mixins/dialogMixin'
import { setCommission } from '@/api/src/salesmanCommission'
import {getPageList} from '@/api/src/returnedMoney'
export default {
  name: 'ConfirmationPop',
  mixins: [dialogMixin],
  props: {
    params: {
      type: Object,
      required: true
    },
    verifyDate: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
      remark: '', // 备注
      returnedData: [] // 回款保存核发提成
    }
  },
  computed: {
  },
  methods: {
    onCancel () {
      this.$emit('onCancel', false)
    },
    submit () {
      this.$confirm('此操作将核算业绩, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        this.verifyDate.forEach(item => {
          this.returnedData.push({returnedNo: item.returnedNo, verifyPrice: item.verifyPrice, id: item.id})
        })
        console.log(this.returnedData)
        await setCommission({id: this.params.obj.id, status: this.params.obj.status, verifyPriceAll: this.params.obj.verifyPrice, remark: this.remark, returnedData: this.returnedData})
        this.$emit('closeDetailDialog')
        this.onCancel()
        this.$message({
          type: 'success',
          message: '提交成功!'
        })
      }).catch(() => {})
    }
  }
}
</script>

<style></style>
